package com.forestar.mapControl.utils.mapConvert.geometry;

import com.forestar.mapControl.utils.mapConvert.geometry.coordinatesystem.CoordinateSystem;
import com.forestar.mapControl.utils.mapConvert.geometry.coordinatesystem.ZoneType;
import com.forestar.mapControl.utils.mapConvert.geometry.utils.GeometryUtils;
import com.mapzone.api.geometry.mzMultiPolygon;
import com.mapzone.api.geometry.mzPolygon;

public class GeoMultiPolygon implements IGeometry
  {

    private CoordinateSystem coordSystem;

    private mzMultiPolygon internalmzMultiPolygon;

    public GeoMultiPolygon(CoordinateSystem coordSystem, mzMultiPolygon multiPolygon)
      {
        this.coordSystem = coordSystem;
        this.internalmzMultiPolygon = multiPolygon;
      }
   private int id;

    public void setId(int id)
      {
        this.id = id;
      }

    public int getId()
      {
        return id;
      }

    @Override
    public GeometryType getGeometryType()
      {
        return GeometryType.GeometryTypeMultiPolygon;
      }

    public double[] getPoints(int polygonIndex, int ringIndex)
      {
        return null;
      }

    public int getExteriorRingCount()
      {
        return 0;
      }

    @Override
    public CoordinateSystem getCoordinateSystem()
      {
        return coordSystem;
      }

    public int[] getRingsPointCount()
      {
        return null;
      }

    public int getInnerRingCount(int exteriorRingIndex)
      {
        return 0;
      }

    public double[] getInnerRingPoints(int exteriorRingIndex, int innerRingIndex)
      {
        return null;
      }

    public double[] getExteriorRingPoints(int exteriorRingIndex, int innerRingIndex)
      {
        return null;
      }

    @Override
    public Envelope getEnvelope()
      {
        return GeometryUtils.getEnvelope(internalmzMultiPolygon);
      }

    public int getPointsCount()
      {
        return 0;
      }

    @Override
    public void setCoordinateSystem(CoordinateSystem coordSystem)
      {
        this.coordSystem = coordSystem;
      }

    //没有投影的面积
    public double getArea()
      {
        return internalmzMultiPolygon.getArea();
      }

    //投影后的面积
    public double getAreaEx(ZoneType zoneType)
      {
        //参数：nZone，0:3度分带加带号；1:3度分带不加带号；2:6度分带加带号，3:6度分带不加带号
        return internalmzMultiPolygon.GetAreaEx(zoneType.getValue());
      }

    @Override
    public IGeometry Clone()
      {
        mzMultiPolygon m_mzMultiPolygonClone = (mzMultiPolygon) this.internalmzMultiPolygon.clone();
        return new GeoMultiPolygon(this.coordSystem, m_mzMultiPolygonClone);
      }

    @Override
    public byte[] getBlob()
      {
        return GeoConverter.Geom2Blob(this.internalmzMultiPolygon);
      }

    @Override
    public Object getInternalObject()
      {
        return internalmzMultiPolygon;
      }

    @Override
    public boolean isSimple()
      {
        return internalmzMultiPolygon.IsSimple();
      }

    public int getPolygonCount()
      {
        return internalmzMultiPolygon.getPolygonCount();
      }

    public GeoPolygon getPolygon(int nIndex)
      {
        mzPolygon m_mzPolygon = internalmzMultiPolygon.GetPolygon(nIndex);
        return new GeoPolygon(coordSystem, m_mzPolygon);
      }

    //获取所有环的长度和
    public double getLength()
      {
        return internalmzMultiPolygon.getLength();
      }

    //获取所有环的长度和,如果有跨带环，则先分割，再投影到各自SRID下，再求长度和
    public double getLengthEx(ZoneType zoneType)
      {
        return internalmzMultiPolygon.getLengthEx(zoneType.getValue());
      }
  }
